package com.stars.home.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.stars.home.adapter.DriverOrderListAdapter
import com.stars.home.base.MBRFragment
import com.stars.home.databinding.FragmentDriverOrderListBinding
import com.stars.home.model.CompreBean
import com.stars.home.vmodel.DriverOrderListVModel
import com.trailer.base.net.IResp

/**
 *on 2021/5/14
 */
class DriverOrderListFragment: MBRFragment<DriverOrderListVModel, DriverOrderListAdapter, FragmentDriverOrderListBinding>() {


    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
        vm.order_state = arguments?.getString("order_state")


    }

    override fun vmClass(): Class<DriverOrderListVModel> {
        return DriverOrderListVModel::class.java
    }

    override fun binding(inflater: LayoutInflater, container: ViewGroup?): FragmentDriverOrderListBinding {
        return FragmentDriverOrderListBinding.inflate(layoutInflater)
    }

    override fun initAdapter(): DriverOrderListAdapter {
     return DriverOrderListAdapter(vm)
    }

    override fun onListReceive(res: IResp<*>) {
        super.onListReceive(res)

        if (null != res) {

            var list = res.data() as List<CompreBean>
            if (list.isEmpty() && vm.repository().page == 1) {

                binding.listEmpty.visibility = View.VISIBLE
            } else {
                binding.listEmpty.visibility = View.GONE
            }

        }
    }

    override fun title(): String? {
        return null
    }
}
